from django.contrib.auth.views import LoginView as BaseLoginView
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
from .models import *
from django.views.decorators.csrf import csrf_exempt

from django.middleware.csrf import get_token

@csrf_exempt
def login_2(request):
    token=get_token(request)
    return HttpResponse(json.dumps({'token':token}), content_type="application/json,charset=utf-8")

class LoginView(BaseLoginView):
    template_name = 'login.html'
    redirect_authenticated_user = True
